#include<iostream>
#include<pthread.h>
#include<unistd.h>

using namespace std;
void* p;
int n = 5;
void* threadRoutine(void* args)
{
    
    while(n--)
    {
        cout<<"new thread,pid:"<<getpid()<<endl;
        sleep(1);
        if(n==1)
        {
            pthread_exit(p);
        }
    }
    


}

int main()
{
    pthread_t tid;
    pthread_create(&tid, nullptr,threadRoutine,nullptr);
    while(true)
    {
        cout<<"main thread,pid:"<<getpid()<<endl;
        sleep(1);
    }
    
    return 0;
}